home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _4AAA1AECD5804BF08341D126B81403A9 < prev    next >
Text File  |  2004-11-26  |  1KB  |  53 lines

  1. ///campfire particle shader
  2. //input should be 4 points that are the same position
  3. //color0 (diffuse) used normally
  4. //color1 (spec): green,red are tex coord, blue = size modifier
  5. //Luke Lenhart
  6. //(C)2004-2005 Digipen Institute of Technology
  7.  
  8. //world,view,projection transform
  9. float4x4 matWorldViewProj;
  10.  
  11. //camera position in world space
  12. float4 cameraPos;
  13.  
  14. //particle size modifier
  15. float size;
  16.  
  17. //shader input
  18. struct VS_INPUT
  19. {
  20.     float4 Pos : POSITION;
  21.     float4 Color : COLOR0;
  22.     float4 Spec : COLOR1;
  23. };
  24.  
  25. //shader output
  26. struct VS_OUTPUT
  27. {
  28.     float4 Pos : POSITION;
  29.     float4 Color : COLOR;
  30.     float2 Tex0 : TEXCOORD0;
  31. };
  32.  
  33. //shader code
  34. VS_OUTPUT VShader(VS_INPUT In)
  35. {
  36.     VS_OUTPUT Out;
  37.     
  38.     //transform pos and copy tex coord and color over
  39.     Out.Pos=mul(matWorldViewProj,In.Pos);
  40.     Out.Tex0=In.Spec.xy;
  41.     Out.Color=In.Color;
  42.     
  43.     //expand outwards from center point, based on distance and tex coord
  44.     float distmod=0.08f + 1.0f / pow(distance(cameraPos,In.Pos),0.5f);
  45.     float2 posOffset=In.Spec.xy - float2(0.5f,0.5f);
  46.     float sizeMod=(0.5f + In.Spec.z*2.0f);
  47.     
  48.     Out.Pos.xy+=posOffset*distmod*size*sizeMod;
  49.  
  50.     //spit out the results
  51.     return Out;
  52. }
  53.